At the start of the program you will have to call the required namespace like so:
using System.Text.RegularExpressions;
Then in your code the first thing to do is to define the string which you think might be an email address:
string _address = "channels@spiration.co.uk";
Regex emailregex = new Regex("(?<user>[^@]+)@(?<host>.+)");
The following line creates a Regular Expression object called emailregex. This class takes an expression in it's constructor as shown above. Note that it is also possible to do sub-string capturing using the <string> syntax. These substrings are then available in the m.Groups array (for example m.Groups["user"] and m.Groups["host"].
So moving on, the next stage is to create a Match object, which we can use to tell whether or not the regular expression was matcyhed. The match object is set by calling the Match method on the expression and passing in the address.
Match m = emailregex.Match(_address);
from that point, you can then test the result with a simple conditional statement:
if ( m.Success ) {
// success,, so do something;
}else{
// didn't manage to find the regular expression
}
That's really all there is to it.
christo